package com.mobileares.midp.demo.client.page;

import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;
import com.mobileares.midp.widgets.client.tab.CTabPanel;
import com.mobileares.midp.widgets.client.tab.FrameTabPanel;
import com.mobileares.midp.widgets.client.tab.TabPanel;
import com.mobileares.midp.widgets.client.tab.VerticalTabPanel;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-7-22
 * Time: 16:08:01
 * To change this template use File | Settings | File Templates.
 */
public class Tab extends Composite {
    private FlowPanel panel;
    public Tab(){
        panel = new FlowPanel();
        initWidget(panel);
        panel.add(getTab());
        panel.add(new HTML("<br/>"));
        panel.add(getTab2());
        panel.add(new HTML("<br/>"));
//        panel.add(getTab4());
        panel.add(new HTML("<br/>"));
        panel.add(getVTabPanel());
    }
       private Widget getTab() {
        final CTabPanel tab = new CTabPanel();
        tab.addItem("测试1", new Label("a"));
        tab.addItem("测试2", new Label("b"));
        tab.addItem("测试3", new Label("c"));

        tab.addSelectionHandler(new SelectionHandler<Integer>() {
            public void onSelection(SelectionEvent<Integer> integerSelectionEvent) {
//                Window.alert(integerSelectionEvent.getSelectedItem() + "");
            }
        });
           tab.setSelected(0);
        return tab;
    }

    private Widget getTab2() {
        final TabPanel tab = new TabPanel();
        tab.addItem("测试1", new Label("a"));
        tab.addItem("测试2", new Label("b"));
        tab.addItem("测试3", new Label("c"));

        tab.addSelectionHandler(new SelectionHandler<Integer>() {
            public void onSelection(SelectionEvent<Integer> integerSelectionEvent) {
//                Window.alert(integerSelectionEvent.getSelectedItem() + "");
            }
        });
        tab.setSelected(0);
        
        return tab;
    }
      private Widget getTab4() {
        final FrameTabPanel tab = new FrameTabPanel();
        tab.addItem("测试1", new Label("a"));
        tab.addItem("测试2", new Label("b"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addItem("测试3", new Label("c"));
        tab.addSelectionHandler(new SelectionHandler<Object>() {
            public void onSelection(SelectionEvent<Object> objectSelectionEvent) {
                com.google.gwt.user.client.Window.alert((String) objectSelectionEvent.getSelectedItem());
            }
        });

        return tab;
    }
     private Widget getVTabPanel(){
        VerticalTabPanel vt = new VerticalTabPanel(200,500);
        vt.addTabItem("操作界面",new Label("czjm"));
        vt.addTabItem("系统管理",new Label("xtgl"));
        vt.addTabItem("个人信息",new Label("个人信息"));
        return vt;
    }
}
